package com.etb.wisdom.eframe.framework.service.impl;

import org.apache.commons.lang3.StringUtils;
import org.springframework.stereotype.Service;

import com.etb.core.service.ETBService;
import com.etb.core.utils.SequenceUtil;
import com.etb.wisdom.eframe.framework.service.AppFuncgroupService;
import com.etb.wisdom.eframe.model.AppFuncgroup;

@Service
public class AppFuncgroupServiceImpl extends ETBService implements AppFuncgroupService {

	@Override
	public void save(AppFuncgroup group) {
		service.save(group);
		if(StringUtils.isBlank(group.getUplevelid())) {
			group.setFuncgroupseq(group.getId());
		} else {
			AppFuncgroup uplevelGroup = new AppFuncgroup();
			uplevelGroup.setId(group.getUplevelid());
			service.extend(uplevelGroup);
			group.setFuncgroupseq(SequenceUtil.generateNewSequence(uplevelGroup.getFuncgroupseq(), group.getId()));
		}
		service.save(group);
	}
}
